package view
{
	import model.DataProxy;
	import model.MessageProxy;
	import model.ViewProxy;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class PopupViewMediator extends Mediator implements IMediator
	{
		public static const NAME:String 				= "PopupViewMediator";
		
		private var popupView:PopupView;
		
		public function PopupViewMediator( viewComponent:Object = null )
		{
			super( NAME, viewComponent );
		}
		
		override public function onRegister():void
		{
			popupView = new PopupView();
			popupView.init( viewProxy.vo);
			
			viewProxy.vo.popupView = popupView;
			
			viewComponent.addChild( popupView );
		}
		
		override public function listNotificationInterests():Array
		{
			return [ PopupView.SHOW ];
		}
		
		override public function handleNotification( notification:INotification) :void
		{
			var name:String = notification.getName();
			var body:Object = notification.getBody();
			
			switch( name )
			{
				case PopupView.SHOW:
					popupView.show( body );
					break;
			}
		}
		
		public function get dataProxy():DataProxy
		{
			return facade.retrieveProxy( DataProxy.NAME ) as DataProxy;
		}
		
		public function get viewProxy():ViewProxy
		{
			return facade.retrieveProxy( ViewProxy.NAME ) as ViewProxy;
		}
		
		private function get messageProxy():MessageProxy
		{
			return facade.retrieveProxy( MessageProxy.NAME ) as MessageProxy;
		}
	}
}